import { getDirname, path } from "vuepress/utils";
import { hopeTheme } from "vuepress-theme-hope";
import type { ThemeOptions } from "vuepress-theme-hope";
import { enNavbar, zhNavbar } from "../navbar/index.js";
import { enSidebar, zhSidebar } from "../sidebar/index.js";

const __dirname = getDirname(import.meta.url);

export default oneTheme => ({
  name: "vuepress-theme-one",

  extends: hopeTheme({
    hostname: "https://xksaturn.com",

    author: {
      name: "暖暖",
      url: "https://xksaturn.com",
    },

    lastUpdated: false,

    iconAssets: "fontawesome-with-brands",

    // logo: "https://image.xiaosaturn.com/Yunyi-Huang/sleep-red-book-1m.png",
    logo: "https://image.xiaosaturn.com/Yunyi-Huang/4CDBC286-1ED4-4A8A-A78F-07F079DED9E7.jpeg",

    docsDir: "src",

    fullscreen: true,

    blog: {
      medias: {
        Baidu: "https://example.com",
        BiliBili: "https://example.com",
      },
    },

    locales: {
      "/zh/": {
        // navbar
        navbar: zhNavbar,

        // sidebar
        sidebar: zhSidebar,

        footer: "暖暖",

        copyright: "Copyright © 2024 暖暖",

        displayFooter: true,

        blog: {
          description: "暖暖的生活记录",
          intro: "/zh/intro.html",
          articleInfo: ["Author", "PageView", "Original", "Date", "Category"]
        },

        metaLocales: {
          editLink: "在 GitHub 上编辑此页",
        },
      },

      /**
       * English locale config
       */
      "/": {
        // navbar
        navbar: enNavbar,

        // sidebar
        sidebar: enSidebar,

        footer: "Amara",

        copyright: "Copyright © 2024 Amara",

        displayFooter: true,

        blog: {
          description: "Record Every Day",
          intro: "/intro.html",
          articleInfo: ["Author", "PageView", "Original", "Date", "Category"]
        },

        // page meta
        metaLocales: {
          editLink: "Edit this page on GitHub",
        },
      },
    },

    encrypt: {
      config: {
        "/demo/encrypt.html": ["1234"],
        "/zh/demo/encrypt.html": ["1234"],
      },
    },

    plugins: {
      blog: true,
      comment: {
        provider: "Waline",
        serverURL: "https://com.xksaturn.com/",
      },

      components: {
        components: ["Badge", "VPCard"],
      },

      // These features are enabled for demo, only preserve features you need here
      mdEnhance: {
        align: true,
        attrs: true,
        codetabs: true,
        component: true,
        demo: true,
        figure: true,
        imgLazyload: true,
        imgSize: true,
        include: true,
        mark: true,
        stylize: [
          {
            matcher: "Recommended",
            replacer: ({ tag }) => {
              if (tag === "em")
                return {
                  tag: "Badge",
                  attrs: { type: "tip" },
                  content: "Recommended",
                };
            },
          },
        ],
        sub: true,
        sup: true,
        tabs: true,
        tasklist: true,
        vPre: true,
        mathjax: true,
      },

      searchPro: {
        indexContent: true,
        autoSuggestions: true,
        queryHistoryCount: 10,
      },

      prismjs: true,
    },
  }, { custom: true }),

  alias: {
    // 你可以在这里覆盖或新增别名
    // 比如这里我们将 vuepress-theme-hope 主页组件改为自己主题下的 components/HomePage.vue
    "@theme-hope/components/HomePage": path.resolve(
      __dirname,
      // "./components/HomePage.vue",
      "./HomeLayout.vue",
    ),
  },
});
